package LeetCode.month01.day28;

import java.util.Arrays;

public class No2300 {
    public int[] successfulPairs(int[] spells, int[] potions, long success) {
        int m = spells.length;
        int n = potions.length;
        int[] res = new int[m];
        Arrays.sort(potions);
        for (int i = 0; i < m; i++) {
            res[i] = getNum(spells[i],potions,success);
        }
        return res;
    }

    public static int getNum(int k,int[] p,long success){
        int left = 0,right = p.length-1;
        int index = -1;
        while(left<=right){
            int mid = left+(right-left)/2;
            if((long)k*p[mid]>=success){
                right = mid-1;
            }else{
                left = mid+1;
            }
        }
        return p.length-left;
    }
}
